\doxysection{C\+:/\+Users/\+ASUS/\+Desktop/dm-\/ctrl\+H7-\/balance-\/9025test/modules/can\+\_\+comm/can\+\_\+comm.h File Reference}
\hypertarget{can__comm_8h}{}\label{can__comm_8h}\index{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/modules/can\_comm/can\_comm.h@{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/modules/can\_comm/can\_comm.h}}


用于多机\+CAN通信的收发模块  


{\ttfamily \#include "{}bsp\+\_\+can.\+h"{}}\newline
{\ttfamily \#include "{}daemon.\+h"{}}\newline
\doxysubsubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \mbox{\hyperlink{struct_c_a_n_comm_instance}{CANComm\+Instance}}
\item 
struct \mbox{\hyperlink{struct_c_a_n_comm___init___config__s}{CANComm\+\_\+\+Init\+\_\+\+Config\+\_\+s}}
\end{DoxyCompactItemize}
\doxysubsubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{can__comm_8h_add342d0e10b78abf72ae19f079e69cd5}\label{can__comm_8h_add342d0e10b78abf72ae19f079e69cd5} 
\#define {\bfseries MX\+\_\+\+CAN\+\_\+\+COMM\+\_\+\+COUNT}~4
\item 
\Hypertarget{can__comm_8h_a88e9b6474304ead55645ad38f1936459}\label{can__comm_8h_a88e9b6474304ead55645ad38f1936459} 
\#define {\bfseries CAN\+\_\+\+COMM\+\_\+\+MAX\+\_\+\+BUFFSIZE}~60
\item 
\Hypertarget{can__comm_8h_a057c71fe869996752afde86bfc8e2cd3}\label{can__comm_8h_a057c71fe869996752afde86bfc8e2cd3} 
\#define {\bfseries CAN\+\_\+\+COMM\+\_\+\+HEADER}~\textquotesingle{}s\textquotesingle{}
\item 
\Hypertarget{can__comm_8h_a0e27ddd237d5911ccb21e43c691ef6b0}\label{can__comm_8h_a0e27ddd237d5911ccb21e43c691ef6b0} 
\#define {\bfseries CAN\+\_\+\+COMM\+\_\+\+TAIL}~\textquotesingle{}e\textquotesingle{}
\item 
\Hypertarget{can__comm_8h_ad34b43a66d5b4cc499f2d5a5674392c7}\label{can__comm_8h_ad34b43a66d5b4cc499f2d5a5674392c7} 
\#define {\bfseries CAN\+\_\+\+COMM\+\_\+\+OFFSET\+\_\+\+BYTES}~4
\end{DoxyCompactItemize}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{struct_c_a_n_comm_instance}{CANComm\+Instance}} \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{can__comm_8h_a611c266bef866f02414a73b7d5584f86}{CANComm\+Init}} (\mbox{\hyperlink{struct_c_a_n_comm___init___config__s}{CANComm\+\_\+\+Init\+\_\+\+Config\+\_\+s}} \texorpdfstring{$\ast$}{*}comm\+\_\+config)
\begin{DoxyCompactList}\small\item\em 初始化\+CANComm \end{DoxyCompactList}\item 
void \mbox{\hyperlink{can__comm_8h_a034f32d1bf2deb6386ed06690f41a7a6}{CANComm\+Send}} (\mbox{\hyperlink{struct_c_a_n_comm_instance}{CANComm\+Instance}} \texorpdfstring{$\ast$}{*}instance, uint8\+\_\+t \texorpdfstring{$\ast$}{*}data)
\begin{DoxyCompactList}\small\item\em 通过\+CANComm发送数据 \end{DoxyCompactList}\item 
void \texorpdfstring{$\ast$}{*} \mbox{\hyperlink{can__comm_8h_ac3cf44018acff09b65450d846df10b6d}{CANComm\+Get}} (\mbox{\hyperlink{struct_c_a_n_comm_instance}{CANComm\+Instance}} \texorpdfstring{$\ast$}{*}instance)
\begin{DoxyCompactList}\small\item\em 获取\+CANComm接收的数据,需要自己使用强制类型转换将返回的void指针转换成指定类型 \end{DoxyCompactList}\item 
uint8\+\_\+t \mbox{\hyperlink{can__comm_8h_a3e10f1654f1cea65cdb5f1e37912140d}{CANComm\+Is\+Online}} (\mbox{\hyperlink{struct_c_a_n_comm_instance}{CANComm\+Instance}} \texorpdfstring{$\ast$}{*}instance)
\begin{DoxyCompactList}\small\item\em 检查\+CANComm是否在线 \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
用于多机\+CAN通信的收发模块 

\begin{DoxyAuthor}{Author}
Neo \href{mailto:neozng1@hnu.edu.cn}{\texttt{neozng1@hnu.\+edu.\+cn}} 
\end{DoxyAuthor}
\begin{DoxyVersion}{Version}
0.\+1 
\end{DoxyVersion}
\begin{DoxyDate}{Date}
2022-\/11-\/27
\end{DoxyDate}
\begin{DoxyCopyright}{Copyright}
Copyright (c) 2022 HNUYue\+Lu EC all rights reserved 
\end{DoxyCopyright}


\label{doc-func-members}
\Hypertarget{can__comm_8h_doc-func-members}
\doxysubsection{Function Documentation}
\Hypertarget{can__comm_8h_ac3cf44018acff09b65450d846df10b6d}\index{can\_comm.h@{can\_comm.h}!CANCommGet@{CANCommGet}}
\index{CANCommGet@{CANCommGet}!can\_comm.h@{can\_comm.h}}
\doxysubsubsection{\texorpdfstring{CANCommGet()}{CANCommGet()}}
{\footnotesize\ttfamily \label{can__comm_8h_ac3cf44018acff09b65450d846df10b6d} 
void \texorpdfstring{$\ast$}{*} CANComm\+Get (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_c_a_n_comm_instance}{CANComm\+Instance}} \texorpdfstring{$\ast$}{*}}]{instance}{}\end{DoxyParamCaption})}



获取\+CANComm接收的数据,需要自己使用强制类型转换将返回的void指针转换成指定类型 

\begin{DoxyReturn}{Returns}
void\texorpdfstring{$\ast$}{*} 返回的数据指针 
\end{DoxyReturn}
\begin{DoxyAttention}{Attention}
注意如果希望直接通过转换指针访问数据,如果数据是union或struct,要检查是否使用了pack(n) CANComm接收到的数据可以看作是pack(1)之后的,是连续存放的. 如果使用了pack(n)可能会导致数据错乱,并且无法使用强制类型转换通过memcpy直接访问,转而需要手动解包. 强烈建议通过\+CANComm传输的数据使用pack(1) 
\end{DoxyAttention}
\Hypertarget{can__comm_8h_a611c266bef866f02414a73b7d5584f86}\index{can\_comm.h@{can\_comm.h}!CANCommInit@{CANCommInit}}
\index{CANCommInit@{CANCommInit}!can\_comm.h@{can\_comm.h}}
\doxysubsubsection{\texorpdfstring{CANCommInit()}{CANCommInit()}}
{\footnotesize\ttfamily \label{can__comm_8h_a611c266bef866f02414a73b7d5584f86} 
\mbox{\hyperlink{struct_c_a_n_comm_instance}{CANComm\+Instance}} \texorpdfstring{$\ast$}{*} CANComm\+Init (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_c_a_n_comm___init___config__s}{CANComm\+\_\+\+Init\+\_\+\+Config\+\_\+s}} \texorpdfstring{$\ast$}{*}}]{comm\+\_\+config}{}\end{DoxyParamCaption})}



初始化\+CANComm 


\begin{DoxyParams}{Parameters}
{\em config} & CANComm初始化结构体 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
CANComm\+Instance\texorpdfstring{$\ast$}{*} 
\end{DoxyReturn}
\Hypertarget{can__comm_8h_a3e10f1654f1cea65cdb5f1e37912140d}\index{can\_comm.h@{can\_comm.h}!CANCommIsOnline@{CANCommIsOnline}}
\index{CANCommIsOnline@{CANCommIsOnline}!can\_comm.h@{can\_comm.h}}
\doxysubsubsection{\texorpdfstring{CANCommIsOnline()}{CANCommIsOnline()}}
{\footnotesize\ttfamily \label{can__comm_8h_a3e10f1654f1cea65cdb5f1e37912140d} 
uint8\+\_\+t CANComm\+Is\+Online (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_c_a_n_comm_instance}{CANComm\+Instance}} \texorpdfstring{$\ast$}{*}}]{instance}{}\end{DoxyParamCaption})}



检查\+CANComm是否在线 


\begin{DoxyParams}{Parameters}
{\em instance} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
uint8\+\_\+t 
\end{DoxyReturn}
\Hypertarget{can__comm_8h_a034f32d1bf2deb6386ed06690f41a7a6}\index{can\_comm.h@{can\_comm.h}!CANCommSend@{CANCommSend}}
\index{CANCommSend@{CANCommSend}!can\_comm.h@{can\_comm.h}}
\doxysubsubsection{\texorpdfstring{CANCommSend()}{CANCommSend()}}
{\footnotesize\ttfamily \label{can__comm_8h_a034f32d1bf2deb6386ed06690f41a7a6} 
void CANComm\+Send (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_c_a_n_comm_instance}{CANComm\+Instance}} \texorpdfstring{$\ast$}{*}}]{instance}{, }\item[{uint8\+\_\+t \texorpdfstring{$\ast$}{*}}]{data}{}\end{DoxyParamCaption})}



通过\+CANComm发送数据 


\begin{DoxyParams}{Parameters}
{\em instance} & cancomm实例 \\
\hline
{\em data} & 注意此地址的有效数据长度需要和初始化时传入的datalen相同 \\
\hline
\end{DoxyParams}
